#include <unordered_map>
#include <iostream>
#include <string>
#include <typeinfo>
#include <map>
using namespace std;
#include <algorithm>
#include <vector>
bool compare(const pair<string, int> &a, const pair<string, int> &b)
{
    if (a.second == b.second)
        return a.first < b.first;
    else
        return a.second > b.second;
}
int main()
{

    map<string, int> m{{"a", 1}, {"b", 2}, {"c", 3}};

    vector<pair<string, int>> v(m.begin(), m.end()); //将map中的元素拷贝到vector中

    sort(v.begin(), v.end(), compare); //实现value的排序
    for (int i = 0; i < v.size(); i++)
    {
        cout << v[i].first;
    }
    cout << m["a"];
    m["a"] = 3;
    cout << m["a"];
    cout << (*v.end()).first;
    cout << v[2].first;
}
